<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <script>
        // async function test1() {
        //     console.log(1);
        //     return 2;
        // }

        function test1() {
            return new Promise((resolve, reject) => {
                console.log(1);
                setTimeout(() => {
                    resolve(2);
                }, 1000);
            })
        }

        async function test2() {
            const result = await test1();  // await后面的都是异步代码
            console.log(result);
            console.log(3);  // 异步的
            return 3;    // 异步的
        }

        console.log(test2());  // test2的返回pro开始是挂起状态，执行完return后，变成已决，状态数据为 3
        
    </script>

</body>

</html>